export const userRegistory = {
    nickName: "",
    phone: "",
    username: "",
    password: "",
    passwordConfirm: ""
}

//校验2次密码
const validatePass2 = (rule,value, callback) => {
    if (value === "") {
        callback(new Error("请再次输入密码"));
    } else if (value !== userRegistory.password) {
        callback(new Error("两次输入密码不一致!"));
    } else {
        callback();
    }
};

export const userRegistoryRules = {
    nickName: [
        {
            message: "姓名不能为空",
            required: true,
            trigger: "blur",
        },
        {
            min: 2,
            max: 30,
            message: "长度在2到30个字符",
            trigger: "blur",
        },
    ],
    phone: [
        {
            message: "联系手机不能为空",
            required: true,
            trigger: "blur",
        },
    ],
    username: [
        {
            message: "账号不能为空",
            required: true,
            trigger: "blur",
        },
    ],
    password: [
        {
            required: true,
            message: "密码不能为空",
            trigger: "blur",
        },
        {
            min: 6,
            max: 30,
            message: "密码长度为6到30个字符",
            trigger: "blur",
        },
    ],
    passwordConfirm: [
        {
            required: true,
            message: "再次确认密码不能为空",
            trigger: "blur",
        },
        {
            min: 6,
            max: 30,
            message: "密码长度为6到30个字符",
            trigger: "blur",
        },
        { validator: validatePass2, trigger: "blur" },
    ],
}

